import datetime
import os
import logging

from models import *
from google.appengine.ext import db
from google.appengine.api import users

class UserService:
	def getUser(self,googleuser):
		return BookUser.gql("WHERE user = :1",googleuser).get()
		#return db.GqlQuery("SELECT * FROM BookUser WHERE user = :1 ORDER BY name LIMIT 1",googleuser).get()
		
	def createUser(self, googleuser):
		user = BookUser(user = googleuser)
		user.put()
		return user
	
	def clear(self):
		users = db.GqlQuery("SELECT * FROM BookUser")
		for user in users:
			user.delete()